home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Color;
- import java.io.FileInputStream;
- import java.io.Serializable;
- import java.util.Properties;
-
- public class Config implements Serializable {
- protected static final String NAME = "NewsMac";
- protected static final String VERSION = "1.1";
- protected static final int MAJOR_VERSION = 1;
- protected static final int MINOR_VERSION = 1;
- protected static final Color SELECTION_COLOUR = new Color(49, 140, 222);
- protected static final String CHANNEL_PATH = "newsmac.app/contents/resources/";
- protected static final String CHANNEL_DATABASE = "channel_database.data";
- protected static final String USER_CHANNEL_PATH = "/library/channels/";
- protected static final String CONFIG_PATH = "/library/preferences/";
- protected static final String IMAGE_PATH = "newsmac.app/contents/resources/";
- protected static final String CHANNEL_SETTINGS = "/library/preferences/NewsMac Channel Settings";
- protected static final String SYSTEM_FONT = "Lucida Grande";
- protected static final String ONLINE_DATABASE = "http://homepage.mac.com/roryp/channel_database.data";
- protected static final String UPDATE = "http://homepage.mac.com/roryp/update.data";
- protected static final String HOMEPAGE = "http://users.aber.ac.uk/rlp9/newsmac";
- private String home = "";
- private boolean cache = false;
- private boolean broadband = true;
- private boolean checkForUpdate = true;
- private boolean checkForChannelUpdate = true;
- private boolean myNewsSwitch = true;
- private boolean autoDownload = true;
- private boolean downloadAll = false;
- private boolean downloadFavorites = true;
- private boolean saveChannelState = true;
- private boolean saveAllHeadlines = false;
-
- protected String getHome() {
- return this.home;
- }
-
- protected void setHome(String theValue) {
- this.home = theValue;
- }
-
- protected void setCheckUpdate(boolean value) {
- this.checkForUpdate = value;
- }
-
- protected boolean isCheckUpdate() {
- return this.checkForUpdate;
- }
-
- protected void setCheckChannelUpdate(boolean value) {
- this.checkForChannelUpdate = value;
- }
-
- protected boolean isCheckChannelUpdate() {
- return this.checkForChannelUpdate;
- }
-
- protected void setAutoDownload(boolean value) {
- this.autoDownload = value;
- }
-
- protected boolean isAutoDownload() {
- return this.autoDownload;
- }
-
- protected void setDownloadAdd(boolean value) {
- this.downloadAll = value;
- }
-
- protected boolean isDownloadAdd() {
- return this.downloadAll;
- }
-
- protected void setDownloadFavorites(boolean value) {
- this.downloadFavorites = value;
- }
-
- protected boolean isDownloadFavorites() {
- return this.downloadFavorites;
- }
-
- protected void setBroadband(boolean speed) {
- this.broadband = speed;
- }
-
- protected boolean isBroadband() {
- return this.broadband;
- }
-
- protected void setMyNewsSwitch(boolean value) {
- this.myNewsSwitch = value;
- }
-
- protected boolean isMyNewsSwitch() {
- return this.myNewsSwitch;
- }
-
- protected void setSaveState(boolean value) {
- this.saveChannelState = value;
- }
-
- protected boolean isSaveState() {
- return this.saveChannelState;
- }
-
- protected void setSaveAll(boolean value) {
- this.saveAllHeadlines = value;
- }
-
- protected boolean isSaveAll() {
- return this.saveAllHeadlines;
- }
-
- protected boolean isCache() {
- return this.cache;
- }
-
- protected void setCache(boolean value) {
- this.cache = value;
- }
-
- protected void savePrefs() throws Exception {
- String configString = "# NewsMac 1.1 Preferences File\n# This is a generated file - DO NOT EDIT!\n\nBroadband=" + this.broadband + "\n" + "Download_favorites=" + this.downloadFavorites + "\n" + "Download_all=" + this.downloadAll + "\n" + "Cache=" + this.cache + "\n" + "Check_for_updates=" + this.checkForUpdate + "\n" + "Check_for_channels=" + this.checkForChannelUpdate + "\n" + "Auto_download=" + this.autoDownload + "\n" + "My_news_switch=" + this.myNewsSwitch + "\n" + "Save_state=" + this.saveChannelState + "\n" + "Save_all=" + this.saveAllHeadlines;
-
- try {
- IOUtil.saveTextFile(this.getPrefsFile(), configString, false);
- } catch (Exception var3) {
- throw new Exception("Config: Error saving preferences.\n\t" + var3);
- }
- }
-
- protected void loadPrefs() throws Exception {
- try {
- Properties props = new Properties();
- props.load(new FileInputStream(this.getPrefsFile()));
- if (props.getProperty("Broadband").equals("true")) {
- this.broadband = true;
- } else {
- this.broadband = false;
- }
-
- if (props.getProperty("Download_favorites").equals("true")) {
- this.downloadFavorites = true;
- } else {
- this.downloadFavorites = false;
- }
-
- if (props.getProperty("Download_all").equals("true")) {
- this.downloadAll = true;
- } else {
- this.downloadAll = false;
- }
-
- if (props.getProperty("Cache").equals("true")) {
- this.cache = true;
- } else {
- this.cache = false;
- }
-
- if (props.getProperty("Check_for_updates").equals("true")) {
- this.checkForUpdate = true;
- } else {
- this.checkForUpdate = false;
- }
-
- if (props.getProperty("Check_for_channels").equals("true")) {
- this.checkForChannelUpdate = true;
- } else {
- this.checkForChannelUpdate = false;
- }
-
- if (props.getProperty("Auto_download").equals("true")) {
- this.autoDownload = true;
- } else {
- this.autoDownload = false;
- }
-
- if (props.getProperty("My_news_switch").equals("true")) {
- this.myNewsSwitch = true;
- } else {
- this.myNewsSwitch = false;
- }
-
- if (props.getProperty("Save_state").equals("true")) {
- this.saveChannelState = true;
- } else {
- this.saveChannelState = false;
- }
-
- if (props.getProperty("Save_all").equals("true")) {
- this.saveAllHeadlines = true;
- } else {
- this.saveAllHeadlines = false;
- }
-
- } catch (Exception var2) {
- throw new Exception("Config: Could not load preferences\n\t" + var2);
- }
- }
-
- protected String getKeywordFile() {
- return this.home + "/library/preferences/" + "NewsMac Keywords";
- }
-
- protected String getPrefsFile() {
- return this.home + "/library/preferences/" + "NewsMac Preferences";
- }
-
- protected String getCacheDir(boolean url) {
- return this.home + "/library/preferences/" + "NewsMac%20Cache/";
- }
-
- protected String getCacheDir() {
- return this.home + "/library/preferences/" + "NewsMac Cache/";
- }
-
- protected void checkConfigDir() throws Exception {
- if (!IOUtil.fileExists(this.home + "/library/preferences/")) {
- throw new Exception("Unable to locate user preferences directory!");
- }
- }
-
- protected void checkCacheDir() {
- if (!IOUtil.fileExists(this.home + "/library/preferences/" + "NewsMac Cache/")) {
- try {
- IOUtil.makeDirectory(this.home + "/library/preferences/" + "NewsMac Cache/");
- } catch (Exception var2) {
- System.out.println(((Throwable)var2).toString());
- }
- }
-
- }
- }
-